import request from "@/utils/request";

// 获取商品列表
export const getGoodsList = (params) => {
  return request({
    method: "get",
    url: "goods",
    params,
  });
};
// 获取商品分类
export const getGoodsCategories = () => {
  return request({
    method: "get",
    url: "categories",
  });
};

// 删除指定商品
export const delGoods = (id) => {
  return request({
    method: "delete",
    url: "goods/" + id,
  });
};
// 图片上传
export const uploadImg = (data) => {
  return request({
    method: "post",
    url: "/private/v1",
    data,
  });
};
// 上传商品
export const uploadGoods = (data) => {
  return request({
    method: "post",
    url: "goods",
    data,
  });
};
// 获取商品属性
export const getGoodsAttribute = (id, params) => {
  return request({
    method: "get",
    url: `categories/${id}/attributes`,
    params,
  });
};
// 添加动态&静态属性
export const addGoodsSel = (id, data) => {
  return request({
    method: "post",
    url: `categories/${id}/attributes`,
    data,
  });
};
// 编辑动态&静态属性
export const editGoodsSel = (id, rid, data) => {
  return request({
    method: "put",
    url: `categories/${id}/attributes/${rid}`,
    data,
  });
};
// 获取单个商品参数
export const getGoodsParams = (id, rid, params) => {
  return request({
    method: "get",
    url: `categories/${id}/attributes/${rid}`,
    params,
  });
};
// 删除单个商品参数
export const delGoodsParams = (id, rid) => {
  return request({
    method: "delete",
    url: `categories/${id}/attributes/${rid}`,
  });
};
